<template>
	<el-dialog :title="titleMap[mode]" v-model="visible" width="85%" destroy-on-close @closed="$emit('closed')" align-center>
        <scTable ref="table" :data="dataList" stripe border show-summary hideDo hidePagination height="650">
            <el-table-column label="母订单号" fixed prop="master_order" align="center" width="150">
                <template #default="scope">
                    <div v-for="item in scope.row.master_order" :key="item.id">
                        <div>{{item.order_no}}</div>
                        <div>{{item.create_time}}</div>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="订单号" fixed align="center" width="150">
                <template #default="scope">
                    <div>{{scope.row.order_no}}</div>
                    <div>{{scope.row.create_time}}</div>
                </template>
            </el-table-column>
            <el-table-column label="商品信息" fixed prop="goods" align="center" width="300">
                <template #default="scope">
                    <div class="shopInfo">
                        <el-image class="img" :src="scope.row.goods.goods_image" :preview-src-list="scope.row.goods.goods_image_item" :initial-index="0" fit="cover" preview-teleported="true" />
                        <div class="right">
                            <div>工厂货号：{{scope.row.factory_number}}</div>
                            <div>批次号：{{scope.row.batch_number}}</div>
                            <div>SKC：{{scope.row.skc}}</div>
                            <div>商品品牌：{{scope.row.brand_name}}</div>
                            <div>客户：{{scope.row.custom_name}}</div>
                            <div>颜色：{{scope.row.goods.colour}}</div>
                            <div v-if="scope.row.sizeCate">商品类别：{{scope.row.sizeCate.title}}</div>
                        </div>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="工厂" prop="linkman" align="center">
                <template #default="scope">
                    <div>{{scope.row.apply_name}}</div>
                </template>
            </el-table-column>
            <el-table-column label="尺寸" prop="goods_size" align="center">
                    <template #default="scope">
                        <div v-for="(item,index) in scope.row.orderDetail" :key="index">
                            {{item.goods_size}}
                        </div>
                    </template>
                </el-table-column>
                <el-table-column label="下单数量" prop="total_count" align="center" :summary="true">
                    <template #default="scope">
                        <div v-for="(item,index) in scope.row.orderDetail" :key="index">
                            {{item.num}}
                        </div>
                    </template>
                </el-table-column>
                <el-table-column label="已要求发货" prop="ask_arrival_count" align="center" :summary="true">
                    <template #default="scope">
                        <div v-for="(item,index) in scope.row.orderDetail" :key="index">
                            {{item.ask_arrival_num}}
                        </div>
                    </template>
                </el-table-column>
                <el-table-column label="未要求发货" prop="no_ask_arrival_count" align="center" :summary="true">
                    <template #default="scope">
                        <div v-for="(item,index) in scope.row.orderDetail" :key="index">
                            {{item.no_ask_arrival_num}}
                        </div>
                    </template>
                </el-table-column>
                <el-table-column label="入库数量" prop="stored_count" align="center" :summary="true">
                    <template #default="scope">
                        <div v-for="(item,index) in scope.row.orderDetail" :key="index">
                            {{item.stored_num}}
                        </div>
                    </template>
                </el-table-column>
                <el-table-column label="入库总数" prop="stored_count" align="center" :show-summary="true"></el-table-column>
                <el-table-column label="工厂价格" prop="factory_money" align="center"></el-table-column>
                <!-- <el-table-column label="客户价格" prop="sell_ask" align="center" width="100"></el-table-column> -->
        </scTable>
        <el-footer style="display:flex;justify-content: end;">
            <el-button @click="visible = false">关 闭</el-button>
        </el-footer>
	</el-dialog>
</template>

<script>
export default {
	emits: ['success', 'closed'],
	data() {
		return {
			mode: "add",
			titleMap: {
				add: '选择扣款单',
				edit: '日账单详情',
			},
			visible: false,
            dataList:[]
		}
	},
	methods: {
		//显示
		open(mode = 'add') {
			this.mode = mode;
			this.visible = true;
			return this
		},
        async setData(data){
            if(this.mode=="edit"){
                var res = await this.$API.order.factory.dayBillDetail.get({id:data.id});
                this.dataList = res.data;
            }else {
                var request = await this.$API.order.custom.dayBillDetail.get({id:data.id});
                this.dataList = request.data;
            }
        },
	}
}
</script>

<style>
</style>
